//
//  WBHomeToolBar.swift
//  微博Demo
//
//  Created by 花化华 on 2016/11/27.
//  Copyright © 2016年 itcast. All rights reserved.
//

import UIKit

class WBHomeToolBar: WBBaseView {

    /// 创建子控件
    //转发按钮
    let retweetButton = UIButton(title: "30", titleColor: UIColor.lightGray, fontSize: 10, image: "timeline_icon_retweet")
    
    //评论按钮
    let commontButton = UIButton(title: "30", titleColor: UIColor.lightGray, fontSize: 10, image: "timeline_icon_comment")
    
    //赞按钮
    let prizeButton = UIButton(title: "30", titleColor: UIColor.lightGray, fontSize: 10, image: "timeline_icon_unlike")
    
    //中间分割线
    let seprateOne = UIImageView(imageName: "timeline_card_bottom_line")
    
    //中间分割线
    let seprateTwo = UIImageView(imageName: "timeline_card_bottom_line")
    
    //上分割线
    let seprateTop = UIImageView(imageName: "timeline_card_bottom_line")
    
    //下分割线
    let seprateBottom = UIImageView(imageName: "timeline_card_bottom_line")
    
    override func wbSetupSubviews() {
        super.wbSetupSubviews()
        setupUI()
    }

}

// MARK: - 设置UI
extension WBHomeToolBar {
    /// 设置UI
    func setupUI () {
        //设置背景色
        backgroundColor = UIColor.white
        
        //分割线的margin
        let margin: CGFloat = 3.0
        //分割线的宽/高
        let seprateWH: CGFloat = 1.0
        
        //添加子视图
        addSubview(retweetButton)
        addSubview(commontButton)
        addSubview(prizeButton)
        addSubview(seprateOne)
        addSubview(seprateTwo)
        addSubview(seprateTop)
        addSubview(seprateBottom)
        
        //自动布局
        retweetButton.snp.makeConstraints { (make) in
            make.left.top.bottom.equalTo(self)
        }
        
        commontButton.snp.makeConstraints { (make) in
            make.top.bottom.equalTo(self)
            make.width.equalTo(retweetButton)
            make.left.equalTo(retweetButton.snp.right)
        }
        
        prizeButton.snp.makeConstraints { (make) in
            make.width.equalTo(commontButton)
            make.top.bottom.right.equalTo(self)
            make.left.equalTo(commontButton.snp.right)
        }
        
        seprateOne.snp.makeConstraints { (make) in
            make.width.equalTo(seprateWH)
            make.left.equalTo(retweetButton.snp.right)
            make.top.equalTo(self).offset(margin)
            make.bottom.equalTo(self).offset(-margin)
        }
        
        seprateTwo.snp.makeConstraints { (make) in
            make.width.equalTo(seprateWH)
            make.left.equalTo(commontButton.snp.right)
            make.top.equalTo(self).offset(margin)
            make.bottom.equalTo(self).offset(-margin)
        }
        
        seprateTop.snp.makeConstraints { (make) in
            make.height.equalTo(seprateWH)
            make.width.equalTo(self)
            make.top.equalTo(self)
        }
        
        seprateBottom.snp.makeConstraints { (make) in
            make.height.equalTo(seprateWH)
            make.width.equalTo(self)
            make.bottom.equalTo(self)
        }
    }
}
